package com.test;

import java.util.Random;

public class role {
    private String name;
    private int blood;


    public role(){

    }
    public  role(String name,int blood){
        this.name = name;
        this.blood = blood;
    }
    public void setName(String name)
    {
        this.name = name;
    }

    public void setBlood(int blood) {
        this.blood = blood;
    }
    public int getBlood(){
        return blood;
    }
    public String getName(){
        return name;
    }
    public void attack(role r)
    {
        Random random = new Random();
        int hurt = random.nextInt(20);
        r.setBlood(r.getBlood()-hurt);
        if(r.getBlood()<0)
        {
            r.setBlood(0);
        }
        System.out.println(this.name+"对"+r.name+"进行了攻击，造成"+hurt+"点伤害"+r.name+"还剩"+r.getBlood()+"点血");
    }
}
